<?php

// //开启session
session_start();


// $_filename = (basename($_SERVER['SCRIPT_NAME'],'.php'));
 
  if(empty($_GET['out']) && empty($_SESSION['admin']) && !empty($_COOKIE['auto_login']) && !empty($_COOKIE['username']) && !empty($_COOKIE['password'])){

  	$_SESSION['admin']['username'] = $_COOKIE['username'];


     if ($a=='login') {

     	header('location:index.php');
     }else{

  	header('location:index.php?c=index&a=index&admin=1');
}


  }

if(!empty($_SESSION['admin']) && $a == 'login'){

        header('location:index.php?c=index&a=index&admin=1');
}

//如果$_SESSION的下标为空时
if(empty($_SESSION['admin'])&& $admin!='home/' && $a!='login' && $a!='code' && $a!='login_out'){
  
    echo '<script>alert("请先登录");location.href="index.php";</script>';die;
     //弹出请先登录并跳转到登录页面
}



if($admin!='home/'){
  $_filename=VIEW_PATH.$admin.$c.'/'.$a.'.html';
}else{
  $_filename=VIEW_PATH.$admin.$c.'/'.$a.'.tpl';
}










// 数据库引用
include_once(LIB_PATH.'my_db.php');


// 调用数据库连接
  $link = db_connect('p301');
if(!empty($_SESSION['admin'])){
  // 灵活拼接

$role = $c.'/'.$a;

// echo $role;die;
 $power_id = getSelectByOne('power',"role='$role'")['id'];

$no_che = array('index','login','login_out');



// if(!in_array($power_id, $_SESSION['admin']['power']) && !in_array($a, $no_che))
// {
//   echo '<script>alert("滚");history.go(-1);</script>';die;
// }
}

include_once(LIB_PATH.'pages.php');


include_once(LIB_PATH.'file.php');
// echo 4;die;
/*引入分类*/
include_once(LIB_PATH.'cate_fun.php');

// 引入缩略图路径
include_once(LIB_PATH.'thumb.php');

  // 配置smarty

  require_once(LIB_PATH.'smarty/Smarty.class.php');

  $smarty = new Smarty();
 
  $smarty->template_dir = '';//视图模板
 
   $smarty->comile_dir = VIEW_PATH.'templates_c/';//smarty编译文件路径
  
  $smarty->cache_dir = VIEW_PATH.'cache/';//缓存路径

  // 边界符修改
  $smarty->left_delimiter='<{';

  $smarty->right_delimiter='}>';


  // var_dump($smarty);die;

$smarty->assign('filename',$_filename);















?>






  
